var express = require("express");
	router = express.Router(),
	fs = require("fs"),
	util = require('util'),
	formidable = require("formidable"),
	form = new formidable.IncomingForm();
	form.uploadDir = "app/public/upData/temporary/";
router.post("/uploadfile" , function(req , res){
    form.parse(req, function(err, fields, files){
		fs.rename(files.upload.path , "app/public/upData/"+files.upload.name , function(error){
			if(error){
				return res.end(error);
			};
			var chunk = {
				state : "ok",
				url : "/upData/"+files.upload.name
			};
			res.writeHead(200, {'content-type': 'text/html'});
			res.end('['+util.inspect(chunk)+']');
		});
    });
});
module.exports = router;